package com.nongcai159.mall.lib_common.widgets

import android.content.Context
import android.util.AttributeSet
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.nongcai159.mall.lib_common.R

/**
 * 导航栏
 *
 *
 * Created by tanbiheng on 2017/9/27.
 */

class NavigateTab : LinearLayout {

    private lateinit var navTabIv: ImageView
    private lateinit var navTabTv: TextView

    var curPosition = 0

    constructor(context: Context) : super(context) {
        init(null)
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
        init(attrs)
    }

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
        init(attrs)
    }

    private fun init(attrs: AttributeSet?) {
        val inflater = context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
        val view = inflater.inflate(R.layout.lib_layout_navigate_tab, this)

        navTabIv = view.findViewById(R.id.navigate_tab_iv)
        navTabTv = view.findViewById(R.id.navigate_tab_tv)
    }

    fun setImageResource(resId: Int) {
        navTabIv.setImageResource(resId)
    }

    fun setText(text: String) {
        navTabTv.text = text
    }

    fun setTextColor(textColor: Int) {
        navTabTv.setTextColor(textColor)
    }

    fun showTextView() {
        navTabTv.visibility = View.VISIBLE
    }

    fun hideTextView() {
        navTabTv.visibility = View.GONE
    }

    fun setTextSize(textSize: Float) {
        navTabTv.setTextSize(textSize)
    }
}
